// 作业:第一个能不能使用promise的异步函数,封装下数据库的查询,二 把sequelize 配置完成,至少能查询一个表去看看sequelize的文档,实现curd
// const { rejects } = require('assert');
let mysql = require('mysql');
// const { resolve } = require('path');
let connection = mysql.createConnection({
    host: "127.0.0.1",
    user: "root",
    password: "root", 
    database: "homework"
 });
 connection.connect();
 function aaPromise(sql){
    return new Promise((resolve,reject)=>{
        connection.query(sql,(err,data)=>{
            if(err!=null) reject(err);
            resolve(data);
            connection.end();
        })
    })
 }
 async function toAsync(sql){
    let aa=await aaPromise(sql);
    console.log(aa);
 }
 toAsync("select * from user where age = 48");